package com.clz.latte.activities;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.ContentFrameLayout;

import com.clz.latte.R;
import com.clz.latte.delegate.LatteDaleGate;

import me.yokeyword.fragmentation.SupportActivity;

/**
 * Created by Administrator on 2017/11/16.
 * 承载Fragment的Activity
 */

public abstract class ProxyActivity extends SupportActivity {

    public abstract LatteDaleGate setRootDeleGate();

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initContainer(savedInstanceState);
    }

    @SuppressLint("ResourceType")
    public void initContainer(@Nullable Bundle savedInstanceState) {
        final ContentFrameLayout contentFrameLayout = new ContentFrameLayout(this);
        contentFrameLayout.setId(R.id.delegate_container);
        setContentView(contentFrameLayout);
        if (savedInstanceState == null) {
            loadRootFragment(R.id.delegate_container, setRootDeleGate());
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        System.gc();
        System.runFinalization();
    }
}
